package com.zcxy.mybatis.service;

import com.zcxy.exception.BusinessException;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zcc
 * @version 1.0.0
 * @ClassName QueryCondition.java
 * @Description TODO
 * @createTime 2020年02月22日 15:12:00
 */
@Data
public class ValiteCondition {
    List<String> filedNames = new ArrayList<>();
    List<Object> fildeValues = new ArrayList<>();

    public ValiteCondition(Object... objs) {
        filedNames = new ArrayList<>();
        fildeValues = new ArrayList<>();
        if (objs.length % 2 == 1) {
            throw new BusinessException("校验的数组必须为偶数");
        }
        for (int i = 0; i < objs.length; i++) {
            if (i % 2 == 1) {
                fildeValues.add(objs[i]);
            } else {
                filedNames.add(objs[i].toString());
            }
        }
    }
}
